<template>
  <div class="container1" :class="{ print: type == '打印' }">
    <DocHeader fromDoc="vte" :title="title"> </DocHeader>
    <div class="content">
      <div class="flex bort borl borr">
        <div class="flex-1 pad8 tac borr">风险等级</div>
        <div class="flex flex-5">
          <el-radio v-model="pageData.riskLevel" label="低危" />
          <el-radio v-model="pageData.riskLevel" label="中危" />
          <el-radio v-model="pageData.riskLevel" label="高危" />
        </div>
      </div>
      <div class="flex borb bort borl borr">
        <div class="flex-1 pad8 tac borr">防范措施</div>
        <div class="flex-5">
          <div class="flex">
            <div class="flex-1 pad8 tac borr">基础预防</div>
            <div class="flex-5">
              <el-checkbox
                v-model="pageData.basicPrevention"
                class="borb"
                label="b1"
              >
                如无禁忌，应抬高卧床患者的下肢，使下肢高于心脏平面20-30cm
              </el-checkbox>
              <el-checkbox
                v-model="pageData.basicPrevention"
                class="borb"
                label="b2"
              >
                避免膝下放置硬枕和过度屈髋
              </el-checkbox>
              <el-checkbox
                v-model="pageData.basicPrevention"
                class="borb"
                label="b3"
              >
                指导和协助卧床患者下肢主动和被动运动，包括踝泵运动和股四头肌功能锻炼
              </el-checkbox>
              <el-checkbox
                v-model="pageData.basicPrevention"
                class="borb"
                label="b4"
              >
                尽早下床活动
              </el-checkbox>
              <el-checkbox
                v-model="pageData.basicPrevention"
                class="borb"
                label="b5"
              >
                避免下肢和患肢静脉穿刺
              </el-checkbox>
              <el-checkbox
                v-model="pageData.basicPrevention"
                class="borb"
                label="b6"
              >
                病情允许下，指导每日饮水1500-2000ml
              </el-checkbox>
              <el-checkbox
                v-model="pageData.basicPrevention"
                class="borb"
                label="b7"
              >
                戒烟限酒，平衡膳食，控制体重
              </el-checkbox>
              <el-checkbox
                v-model="pageData.basicPrevention"
                class="borb"
                label="b8"
              >
                控制血糖、血脂
              </el-checkbox>
              <el-checkbox
                v-model="pageData.basicPrevention"
                class="borb"
                label="b9"
              >
                不宜久坐
              </el-checkbox>
              <el-checkbox v-model="pageData.basicPrevention" label="b10">
                健康宣教
              </el-checkbox>
            </div>
          </div>
          <div class="flex bort">
            <div class="flex-1 pad8 tac borr">机械预防</div>
            <div class="flex-5">
              <el-checkbox
                v-model="pageData.mechanicalPrevention"
                class="borb"
                label="j1"
              >
                抗血栓袜
              </el-checkbox>
              <el-checkbox
                v-model="pageData.mechanicalPrevention"
                class="borb"
                label="j2"
              >
                静脉血栓泵
              </el-checkbox>
              <el-checkbox v-model="pageData.mechanicalPrevention" label="j3">
                足底加压泵
              </el-checkbox>
            </div>
          </div>
          <div class="flex bort">
            <div class="flex-1 pad8 tac borr">药物预防</div>
            <div class="flex-5">
              <el-checkbox
                v-model="pageData.drugPrevention"
                class="borb"
                label="y1"
              >
                出现伤口渗血、皮下血肿、脏器或粘膜出血、月经量增多，立即汇报处理
              </el-checkbox>
              <el-checkbox v-model="pageData.drugPrevention" label="y2">
                关注实验室检查结果包括INR、PT、APTT、PLT，如有异常立即汇报处理
              </el-checkbox>
            </div>
          </div>
          <div class="flex bort">
            <div class="flex-1 pad8 tac borr">健康宣教</div>
            <div class="flex-5">
              <el-checkbox
                v-model="pageData.healthEducation"
                class="borb"
                label="k1"
              >
                出现肢体疼痛、麻木、气促、呼吸困难等，立即告知医护人员
              </el-checkbox>
              <el-checkbox v-model="pageData.healthEducation" label="k2">
                若出现皮肤瘀斑、牙龈出血、鼻出血、尿血、便血或黑便、月经量增多，及时告知医护人员
              </el-checkbox>
            </div>
          </div>
          <div class="flex bort" style="height: 42px">
            <div class="flex-1 pad8 tac borr">其他</div>
            <div class="flex-5 flex">
              <el-checkbox v-model="pageData.other" class="mr-20">
              </el-checkbox>
              <input v-model="pageData.otherContent" class="w-100p p-2 m-0" />
            </div>
          </div>
        </div>
      </div>
      <div class="borb borl borr p-12-5">
        备注：1.VTE风险首次评估后记录 2.手术后再次记录 3.病情变化随时记录
      </div>
      <div class="flex flex-align-center mt-6 p-5">
        <span>签名：</span>
        <img
          v-if="signPhoto(pageData.sign, 'nursingDocument', 62)"
          :src="
            'data:image/png;base64,' +
            signPhoto(pageData.sign, 'nursingDocument', 62)
          "
          alt=""
          style="display: block; max-width: 98%; height: 24px"
          @click="handleSignImgClear"
        />
        <input
          v-else
          v-model="pageData.sign"
          class="w-4 p-2 m-0"
          @blur="handleSignInputBlur"
        />
        <span class="ml-10" style="margin-left: 30%">时间：</span>
        <DateSelection
          v-model="pageData.date"
          value-format="yyyy-MM-dd HH:mm"
          :simple-op="true"
          :date-picker-show="true"
          :date-show="true"
          :no-clear="true"
          :hasBorder="false"
          :needTimeIcon="false"
          :display-num="!pageData.date"
          style="padding: 0"
        />
      </div>
    </div>
  </div>
</template>
<script>
import { cloneDeep, pick } from 'lodash-unified'
import {
  computed,
  defineComponent,
  nextTick,
  onMounted,
  reactive,
  toRefs,
  watch
} from 'vue'

import DateSelection from '@/components/DateSelection/indexV2.vue'
import { useSign } from '@/hooks'
import { getStoreFromInstance } from '@/utils/instance'

import DocHeader from '../DocHeader.vue'
import { baseData } from './baseData.js'

export default defineComponent({
  components: {
    DocHeader,
    DateSelection
  },
  props: {
    data: {
      type: Object,
      default: () => ({})
    },
    title: {
      type: String,
      default: ''
    },
    type: {
      type: String,
      default: ''
    },
    docType: {
      type: [String, Number],
      default: ''
    }
  },
  setup(props) {
    const state = reactive({
      pageData: {}
    })

    const store = getStoreFromInstance()

    const { signPhoto, queryUserSignByName } = useSign()

    const user = computed(() => store.getters.user)

    function initData() {
      if (props.data.jsonText && props.data.jsonText !== '{}') {
        const jsonText = JSON.parse(props.data.jsonText)
        state.pageData = Object.assign(cloneDeep(baseData), jsonText)
      } else {
        nextTick(() => {
          const pageData = cloneDeep(baseData)
          pageData.sign = user.value.name
          queryUserSignByName([user.value.name], 'nursingDocument', 62)
          state.pageData = pageData
        })
      }
    }

    function getParams() {
      return state.pageData
    }

    function handleSignInputBlur() {
      queryUserSignByName([state.pageData.sign], 'nursingDocument', 62)
    }

    function handleSignImgClear() {
      state.pageData.sign = ''
    }

    watch(
      () => props.data,
      () => {
        initData()
      }
    )

    onMounted(() => {
      initData()
    })

    return {
      ...toRefs(state),
      signPhoto,
      getParams,
      handleSignInputBlur,
      handleSignImgClear
    }
  }
})
</script>

<style lang="scss" scoped>
@import '@/views/doc/styles/doc-common.scss';
@import '@/views/doc/styles/doc-fix.scss';
$border: 1px solid #000;

::v-deep .el-checkbox {
  display: block;
  margin-right: 0;
  padding: 12px 5px;
}

::v-deep .el-radio {
  padding: 12px 5px;
}

.mt-6 {
  margin-top: 6px;
}

.p-12-5 {
  padding: 12px 5px;
}

.container1 {
  padding: 20px 0;
  // margin: getpx(30) auto 0;
  // width: calc(100% - 66px);
  font-family: SiYuanSong-Medium;
  text-align: start;

  span {
    font-size: 14px;
  }

  .print-span {
    display: inline-block;
    font-size: 12px;
    border-bottom: 1px solid;
    vertical-align: text-bottom;
    word-break: break-all;
  }
}

.bor-t-box {
  margin-bottom: 10px;
  width: 100%;
  border-top: 1px solid #000;
}

.mt {
  &-3 {
    margin-top: 3px;
  }
}

.ml {
  &-30 {
    margin-left: 30px;
  }

  &-38 {
    margin-left: 38px;
  }

  &-42 {
    margin-left: 42px;
  }

  &-50 {
    margin-left: 50px;
  }

  &-60 {
    margin-left: 60px;
  }

  &-70 {
    margin-left: 70px;
  }

  &-73 {
    margin-left: 73px;
  }

  &-84 {
    margin-left: 84px;
  }

  &-240 {
    margin-left: 240px;
  }
}

.mb {
  &-3 {
    margin-bottom: 3px;
  }

  &-10 {
    margin-bottom: 10px;
  }
}

.mr {
  &-10 {
    margin-right: 10px;
  }

  &-15 {
    margin-right: 15px;
  }

  &-20 {
    margin-right: 20px;
  }
}

.m-0 {
  margin: 0;
}

.m-0-2 {
  margin: 0 2px;
}

.p-2 {
  padding: 2px;
}

.p-10-0 {
  padding: 10px 0;
}

.txt-c {
  text-align: center;

  input {
    text-align: center;
  }
}

.w-1 {
  width: 75px;
}

.w-2 {
  width: 260px;
}

.w-3 {
  width: 89px;
}

.w-4 {
  width: 90px !important;

  :deep {
    .el-input {
      width: 90px;
    }
  }
}

.w-5 {
  width: 76px !important;

  :deep {
    .el-input {
      width: 76px;
    }
  }
}

.w-6 {
  width: 66px;
}

.w-7 {
  width: 100px;
}

.w-8 {
  width: 14px;
}

.w-9 {
  width: 74px;

  :deep {
    .el-input {
      width: 74px;
    }
  }
}

.w-10 {
  width: 25px;
}

.w-11 {
  width: 116px;
}

.w-12 {
  width: 60px;
}

.w-13 {
  width: 127px;
}

.relative {
  position: relative;
}

input {
  margin: 4px 2px;
  font-size: 12px;
}

.flex-end {
  justify-content: flex-end;
}

.inline-block {
  display: inline-block;
}

::v-deep {
  .textarea {
    flex: 1;
    margin-left: 5px;

    .el-textarea__inner {
      padding: 0;
      font-size: 14px;
      color: #000;
      border: none;
      line-height: 1.15;
      resize: none;
      word-break: break-all;
    }
  }

  .el-cascader__tags {
    width: 100%;
    transform: translateY(-61%);

    .el-tag {
      max-width: 60%;
    }
  }

  .el-date-editor {
    padding: 2px;
    width: 100px;

    .el-input__inner {
      font-size: 14px;
    }

    .el-input__suffix {
      display: inline-block;
    }
  }

  .el-select,
  .el-autocomplete {
    margin: 4px 2px;
    border-bottom: 1px solid;

    .el-input__suffix {
      display: inline-block;
      right: -6px;
      top: -3px;

      .el-icon-arrow-up {
        display: none;
      }

      .el-icon-circle-close {
        color: red;
      }
    }

    .el-input__inner {
      text-align: center;
      height: 15px;
      line-height: 15px;
    }
  }

  .el-cascader {
    border-bottom: 1px solid;
    line-height: 15px;
  }

  .el-cascader__search-input {
    height: 15px;
  }

  .el-input .el-input__inner {
    height: 15px !important;
    font-size: 12px;
  }

  .el-input.is-disabled .el-input__inner {
    background-color: #fff;
  }

  input:disabled {
    color: #000;
    background: #fff;
  }

  .el-cascader__search-input {
    margin-left: 0;
  }
}

.img {
  width: 20px;
  vertical-align: sub;
  cursor: pointer;

  &.add {
    margin: 5px 10px 0 0;
  }

  &:not(.add) {
    position: absolute;
    right: -20px;
    top: 3px;
  }
}

.print {
  ::v-deep {
    .el-select {
      padding-bottom: 1px;
      transform: translateY(-1px);
    }
  }

  .container1 {
    .print-spans {
      padding-bottom: 1px;
      transform: translateY(1px);
    }
  }

  input {
    padding-bottom: 1px;
    line-height: 14px;
  }
}
$border: 1px solid #000;

.container {
  padding-top: getpx(50);
  // margin: getpx(30) auto 0;
  // width: calc(100% - 40px);
  font-family: SiYuanSong-Medium;
  text-align: start;
}

.content {
  margin-top: 5px;
}

.inputStyle {
  // font-size: 10px;
  border: none;
  background-color: rgba($color: #000, $alpha: 0%);
  outline: none;
  width: 90%;
  height: 100%;
}

.w40 {
  width: 40px;
}

.w60 {
  width: 60px;
}

.flex {
  display: flex;
}

.tac {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.sta {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.flex {
  @for $i from 1 through 30 {
    &-#{$i} {
      flex: $i;
    }
  }
}

.mb8 {
  margin-bottom: 8px;
}

.borr {
  border-right: 1px solid #000;
}

.bort {
  border-top: 1px solid #000;
}

.borl {
  border-left: 1px solid #000;
}

.borb {
  border-bottom: 1px solid #000;
}

.pad10 {
  padding: 10px;
}

.pad5 {
  padding: 5px;
}

.h30 {
  height: 38px;
}
</style>
